package cn.yudao.ymcc.web.controller;

import cn.yudao.ymcc.dto.SmsCodeDTO;
import cn.yudao.ymcc.result.JSONResult;
import cn.yudao.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid SmsCodeDTO dto){
        JSONResult jsonResult = verifyCodeService.sendSmsCode(dto);
        return jsonResult;
    }

    // /imageCode
    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult getImageVerifyBase(@PathVariable String imageCodeKey){
        System.out.println("ggggg");
        String imgBase = verifyCodeService.getImgBase(imageCodeKey);
        JSONResult jsonResult = new JSONResult();
        jsonResult.setData(imgBase);
        return jsonResult;
    }

}
